package com.deyuanyun.pic.pbf.controller.dto.defect.measure;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.pbf.controller.dto.defect.DefaultCommand;
import com.deyuanyun.pic.pbf.controller.dto.defect.ImgDto;
import com.deyuanyun.pic.pbf.domain.DefectInfo;
import com.deyuanyun.pic.pbf.domain.DefectMeasure;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.wf.support.ProcessDefinitionUtil;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 缺陷测量公共信息类
 *
 * @author hlw
 * @date 2016-6-28
 *
 * History: [修改人][时间][修改描述]
 */
public abstract class MeasureDto<T> extends DefaultCommand {

    /**
     * 缺陷编号
     */
    private String defectNumber;

    /**
     * 缺陷对象类型
     */
    private String featureType;

    /**
     * 检测缺陷类型
     */
    private String featureSubType;

    /**
     * 实测缺陷类型
     */
    private String actualFeatureType;

    /**
     * 实测经度
     */
    private BigDecimal actualX;

    /**
     * 实测纬度
     */
    private BigDecimal actualY;

    /**
     * 实测高度
     */
    private BigDecimal actualZ;

    /**
     * 修复方法（检测修复方法）
     */
    private String planRepairMethod;

    /**
     * 变更修复方法（实际修复方法）
     */
    private String repairMethod;

    /**
     * 工作量
     */
    private String repairWorkload;

    /**
     * 变更修复方法原因
     */
    private String repairRemark;

    /**
     * 缺陷类型 编号
     */
    private String featureTypeCode;

    private Map<String, List<ImgDto>> imgList;

    protected DefectInfo defectInfo;

    public MeasureDto(DefectInfo defectInfo) {
        this.defectInfo = null == defectInfo ? new DefectInfo() : defectInfo;
    }

    protected MeasureDto() {
    }

    public String getFeatureSubType() {
        return featureSubType;
    }

    public void setFeatureSubType(String featureSubType) {
        this.featureSubType = featureSubType;
    }

    public String getDefectNumber() {
        return defectNumber;
    }

    public void setDefectNumber(String defectNumber) {
        this.defectNumber = defectNumber;
    }

    public String getFeatureType() {
        return featureType;
    }

    public void setFeatureType(String featureType) {
        this.featureType = featureType;
    }

    public String getActualFeatureType() {
        return actualFeatureType;
    }

    public void setActualFeatureType(String actualFeatureType) {
        this.actualFeatureType = actualFeatureType;
    }

    public BigDecimal getActualX() {
        return actualX;
    }

    public void setActualX(BigDecimal actualX) {
        this.actualX = actualX;
    }

    public BigDecimal getActualY() {
        return actualY;
    }

    public void setActualY(BigDecimal actualY) {
        this.actualY = actualY;
    }

    public BigDecimal getActualZ() {
        return actualZ;
    }

    public void setActualZ(BigDecimal actualZ) {
        this.actualZ = actualZ;
    }

    public String getPlanRepairMethod() {
        return planRepairMethod;
    }

    public void setPlanRepairMethod(String planRepairMethod) {
        this.planRepairMethod = planRepairMethod;
    }

    public String getRepairMethod() {
        return repairMethod;
    }

    public void setRepairMethod(String repairMethod) {
        this.repairMethod = repairMethod;
    }

    public String getRepairWorkload() {
        return repairWorkload;
    }

    public void setRepairWorkload(String repairWorkload) {
        this.repairWorkload = repairWorkload;
    }

    public String getRepairRemark() {
        return repairRemark;
    }

    public void setRepairRemark(String repairRemark) {
        this.repairRemark = repairRemark;
    }

    public Map<String, List<ImgDto>> getImgList() {
        return imgList;
    }

    public void setImgList(Map<String, List<ImgDto>> imgList) {
        this.imgList = imgList;
    }

    public String getFeatureTypeCode() {
        return featureTypeCode;
    }

    public void setFeatureTypeCode(String featureTypeCode) {
        this.featureTypeCode = featureTypeCode;
    }

    public void fromDomain(DefectMeasure domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }

        // 缺陷编号
        this.defectNumber = defectInfo.getCustomNumber();
        // 缺陷对象类型
        this.featureType = CodeUtil.getName(domain.getFeatureType());
        // 检测缺陷类型
        this.featureSubType = CodeUtil.getName(domain.getFeatureSubtype());
        // 实测缺陷类型
        this.actualFeatureType = CodeUtil.getName(domain.getActualFeaturetype());
        // 实测经度
        this.actualX = domain.getActualX();
        // 实测纬度
        this.actualY = domain.getActualY();
        // 实测高度
        this.actualZ = domain.getActualZ();
        // 修复方法（评价修复方法）
        this.planRepairMethod =  ProcessDefinitionUtil.getProcessDefinitionName(defectInfo.getPlanRepairType());
        // 修复方法（实际修复方法）
        this.repairMethod = ProcessDefinitionUtil.getProcessDefinitionName(defectInfo.getRepairType());
        // 工作量
        this.repairWorkload = defectInfo.getRepairWorkload();
        // 变更修复方法原因
        this.repairRemark = defectInfo.getRepairRemark();

        // 图片
        this.imgList = ImgDto.queryImgDtoMapList(domain.getId());;
    }
}
